<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <link rel="stylesheet" th:href="@{/css/login.css}">
</head>
<body>
    <form action="/login" method="post" onsubmit="return check()">
        <label for="username">用户名&nbsp<input id="username" type="text" placeholder="用户名" name="username"></label><br>
        <label for="password">密&nbsp&nbsp&nbsp码&nbsp<input id="password" type="password" placeholder="密码" name="password"></label>
        <div class="bts">
            <input style="margin-right: 20px;" type="submit" value="登录">
            <button onclick="location.href='/register'" type="button">注册</button>
        </div>
        <p id="error" th:text="${message}"></p>
    </form>
    <div class="footer">
        适用浏览器：chrome
    </div>
</body>
<script>
    function check() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        var error = document.getElementById("error");
        if (username === "") {
            error.innerHTML = "账号不能为空";
            return false;
        } else if (password === "") {
            error.innerHTML = "密码不能为空";
            return false;
        }
        return true;
    }
</script>
</html>